package top.txl.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.txl.entity.Employee;
import top.txl.entity.PageBean;
import top.txl.mapper.EmployeeMapper;
import top.txl.service.EmployeeService;

import java.util.List;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public Employee admin(Employee employee){
        Employee emp = employeeMapper.admin(employee);
        return emp;
    }

    @Override
    public PageBean lists(Integer page, Integer pageSize, String keyWords) {
        PageHelper.startPage(page,pageSize);
        List<Employee> lists = employeeMapper.lists(keyWords);
        Page<Employee> p = (Page<Employee>) lists;
        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;
    }

    @Override
    public void add(Employee employee) {
        employeeMapper.add(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public void delete(Integer id) {
         employeeMapper.delete(id);
    }

    @Override
    public Employee detail(Integer id) {
        Employee emp = employeeMapper.detail(id);
        return emp;
    }

//    @Override
//    public void updateStatus(Employee emp) {
//        employeeMapper.updateStatus(emp);
//    }
}
